package 力扣._165_比较版本号;

class Solution {
    public int compareVersion(String version1, String version2) {
        String[] v1 = version1.split("\\.");
        String[] v2 = version2.split("\\.");
        int len1 = v1.length;
        int len2 = v2.length;
        int len = Math.max(len1,len2);
        for (int i = 0; i < len; i++) {
            int n1 =0;
            if(i<len1)
                n1 = Integer.parseInt(v1[i]);
            int n2 = 0;
            if(i<len2)
                n2 = Integer.parseInt(v2[i]);
            if(n1 != n2)
                return n1 > n2? 1 : -1;
        }
        return 0;
    }
}